package com.wpw.dream.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class QueueDes {

	public static void main(String[] args) {
		/*ArrayBlockingQueue //bounded
		LinkedBlockingQueue //optionally-bounded 
		PriorityBlockingQueue //unbounded
		DelayQueue //unbounded 
		SynchronousQueue //each insert operation must wait for a corresponding remove operation by another  thread, and vice versa.
		LinkedTransferQueue //unbounded
		LinkedBlockingDeque //optionally-bounded
		*/
		/*BlockingQueue<Integer> aq = new ArrayBlockingQueue<>(3);
		for (int i = 0; i < 5; i++) {
			aq.add(i);
		}*/
		/*BlockingQueue<Long> aq = new LinkedBlockingQueue<>(3);
		for (long i = 0; i < 5; i++) {
			aq.add(i);
		}*/
		
		ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
//		newCachedThreadPool.shutdown();
//		newCachedThreadPool.invokeAny(tasks);
//		newCachedThreadPool.invokeAll(tasks)
//		newCachedThreadPool.submit(task);
		ScheduledThreadPoolExecutor s = new ScheduledThreadPoolExecutor(2);
		for (int i = 0; i < 4; i++) {
			s.schedule(new Runnable() {

				@Override
				public void run() {
					System.out.println("2");
				}
			}, i, TimeUnit.SECONDS);
			
		}
		s.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
		
		/*s.submit(task)
		FutureTask<String> futrue = new FutureTask<>(callable);*/
		s.shutdown();
		System.out.println("jies");
	}
}
